//
//  ShopScene.m
//  CandyJump
//
//  Created by Jordy on 11年4月3日.
//  Copyright 2011 Peru Republic. All rights reserved.
//

#import "ShopScene.h"
#import	"MenuScene.h"
#import "CCScrollLayer.h"

@implementation ShopScene

+ (id) scene
{
	CCScene *scene = [CCScene node];
	
	ShopScene *layer = [ShopScene node];
	
	[scene addChild: layer];
	
	return scene;
}
	
- (id) init
{
	if ((self = [super init]))
	{
		// Top menu bar
		CCMenuItem *skillsButton = [CCMenuItemFont itemFromString:@"Skills" target:self selector:@selector(loadSkillsMenu:)];
		CCMenuItem *itemsButton = [CCMenuItemFont itemFromString:@"Items" target:self selector:@selector(loadItemsMenu:)];
		CCMenuItem *charactersButton = [CCMenuItemFont itemFromString:@"Characters" target:self	selector:@selector(loadCharactersMenu:)];
		CCMenu *topSelectionMenu = [CCMenu menuWithItems:skillsButton, itemsButton, charactersButton, nil];
		[topSelectionMenu alignItemsHorizontallyWithPadding:20.0f];
		topSelectionMenu.position = ccp(160,450);
		[self addChild:topSelectionMenu z:1 tag:0];
		
		CCMenuItem *backButton = [CCMenuItemFont itemFromString:@"Back" target:self selector:@selector(gotoMenuScene:)];
		CCMenu *menu = [CCMenu menuWithItems: backButton, nil];
		[menu alignItemsVertically];
		menu.position = ccp(280, 30);
		[self addChild:menu z:1 tag:1];
	}
	return self;
}

- (void) gotoMenuScene:(id) sender
{
	[[CCDirector sharedDirector] replaceScene: [CCTransitionFade transitionWithDuration:0.5f scene:[MenuScene scene]]];
}

- (void) loadSkillsMenu:(id) sender
{
	CCMenuItem *item1 = [CCMenuItemImage itemFromNormalImage:@"Icon-72.png" selectedImage:@"Icon-72.png" target:self selector:@selector(buyItem:)];
	CCMenuItem *item2 = [CCMenuItemImage itemFromNormalImage:@"Icon-Small.png" selectedImage:@"Icon-Small.png" target:self selector:@selector(buyItem:)];
	CCMenuItem *item3 = [CCMenuItemImage itemFromNormalImage:@"Icon.png" selectedImage:@"Icon-Small.png" target:self selector:@selector(buyItem:)];
	
	[self removeChildByTag:2 cleanup:YES];
	CCScrollLayer *scroller = [[CCScrollLayer alloc] initWithMenuItems:[NSMutableArray arrayWithObjects: item1, item2, item3, nil]];
	[self addChild:scroller z:2 tag:2];
	[scroller release];
}

- (void) loadItemsMenu:(id) sender
{
}

- (void) loadCharactersMenu:(id) sender
{
}

- (void) buyItem:(id) sender
{
	NSLog(@"bought item with price : x");
}

- (void) dealloc
{
	[super dealloc];
}

@end
